var base
var path
var utils
var ghandbook
var ghandbook2
var gDiff
var uiflag = false
var allflag = true
var settingpanel
var globalBonus
var statis1 = {}
var statis2 = {}
var statiscontainer
var statiswindow
var summorsys
var bgcnt
var shenqisys
var layertxt
var pieces
var crystals
var spoints
var gsell
var nameeff = []

signal resetData
#signal initMainUI
signal onBattleReady

func _ready():
	#print(chaData.rndPool)
	pass
func _connect():
	pass
func _init():#buff描述也在这
	config.bfDir["<魔化>"] = "增加15%攻击，5%暴击，20%吸血，免疫所有控制状态，<神枪连击>技能冷却减少至2秒，伤害提升至180%，持续18秒，无法叠加效果"
	config.bfDir["<暗龙>"] = "增加15%攻击，10%免伤，免疫所有控制状态，<暗影利爪>技能冷却减少至1秒，<诅咒>触发概率提升10%，持续8秒，无法叠加效果，无法被驱散"
	config.bfDir["<畏缩>"] = "减少20%攻击，每层增加2%效果，每秒减少层数"
	config.bfDir["<毒雾>"] = "减少50%被治疗效果和15%攻速，无法叠加效果，每5秒减少1层"
	config.bfDir["<冰冻>"] = "无法移动和攻击，每秒减少1层"
	config.bfDir["<先手>"] = "开始战斗即使用一次"
	config.bfDir["<毒源>"] = "无法驱散；每秒减少2%生命上限血量[不会致死，伤害可以致死时保留1点生命]；免疫所有和毒有关的buff；持续期间，<毒种>持续时间变为10秒；持续4秒"
	config.bfDir["<毒源>"] = "无法驱散；每秒减少2%生命上限血量[不会致死，伤害可以致死时保留1点生命]；免疫所有和火有关的buff；持续期间，<火种>持续时间变为6秒；持续4秒"
	config.bfDir["<冰源>"] = "无法驱散；每秒减少2%生命上限血量[不会致死，伤害可以致死时保留1点生命]；免疫所有和冰有关的buff（如：结霜、冰冻等）；持续期间，<冰种>持续时间变为10秒；持续4秒"
	config.bfDir["<眩晕>"] = "无法移动和攻击，每2秒减少1层"
	config.bfDir["<平怒>"] = "减少15%暴击率，无法叠加效果，每2秒减少1层"
	config.bfDir["<沉睡>"] = "无法移动和攻击，受到1次攻击有50%概率解除状态，受到2次攻击则必定解除状态（buff效果和特效伤害除外），每2秒减少1层"
	config.bfDir["<暴怒>"] = "暴击率增加10%，无法叠加效果，每2秒减少1层"
	config.bfDir["<石化>"] = "无法移动和攻击，携带者物防和法防降低10%，无法叠加效果，每2秒减少1层"
	config.bfDir["<神战>"] = "回合开始增加3.4%的伤害加成，每五秒提升一层效果，最多叠加五层（无法驱散）"
	config.bfDir["<灼烧>"] = "每秒造成<施法者攻击力（物理或魔法）* 14%>* 层数的真实生命值伤害，每秒减少一层"
	config.bfDir["<诅咒>"] = "两秒后造成<施法者攻击力（物理或魔法）* 30%>* 层数的真实生命值伤害，并减少一层"
	config.bfDir["<禁疗>"] = "携带该状态的单位无法被治疗，无法叠加效果，每2秒减少一层"
	config.bfDir["<魔破>"] = "魔法防御减少20%，无法叠加效果，每2秒减少一层"
	config.bfDir["<破甲>"] = "物理防御减少20%，无法叠加效果，每2秒减少一层"
	config.bfDir["<混乱>"] = "携带单位无法分辨敌友，将使用普通攻击随机攻击全场任意目标，每2秒减少一层"
	config.bfDir["<离间>"] = "携带单位背叛，将使用普通攻击攻击随机一个队友，每2秒减少一层"
	config.bfDir["<圣盾>"] = "携带单位可抵挡一次普通攻击，每一层可抵挡一次攻击"
	config.bfDir["<振奋>"] = "提高30%物攻，无法叠加效果，每2秒减少一层"
	config.bfDir["<沉默>"] = "无法使用技能，无法叠加效果，每秒减少一层"
	config.bfDir["<毒种>"] = "无法驱散，受到所有伤害增加5%[不叠加效果]，持续6秒，若叠加9层，消耗所有层数，对附带者造成<150%物攻>点真伤"
	config.bfDir["<火种>"] = "无法驱散，受到所有伤害增加5%[不叠加效果]，持续3秒，若火种和火有关的buff（例如：<烧灼><灼烧>）同时存在，则消耗所有火种和所有火有关的buff，对敌方造成<生命上限5%>的真伤"
	config.bfDir["<冰种>"] = "无法驱散，受到所有伤害增加5%[不叠加效果]，持续6秒，若叠满9层，则消耗所有冰种对敌方造成<60%物攻>的真伤，并附加1层<冰冻>"
	config.bfDir["<毒>"] = "造成 <基础伤害+百分比物攻> 点特效伤害，每秒减少一层"
	config.bfDir["<随机buff>"] = "包括<毒>、<中毒>、<中·毒>、<毒雾>、<血脉激发>；不同buff组合可能有彩蛋"
	config.bfDir["<中·毒>"] = "每秒造成<附加者生命上限*5%>的真实生命值伤害，最大不超过施法者攻击力10倍，无法叠加效果，每秒减少一层"
	config.bfDir["<森林印记>"] = "单位每携带一层，提升潘对其的伤害3%,最多叠加10层，不可驱散"
	config.bfDir["<反噬>"] = "携带者发出攻击时会遭到<施法者攻击力（物理或魔法） * 10%>的真伤，每两秒减少一层"
	config.bfDir["<模糊>"] = "当有队友存在时，不会被当成普通攻击目标，每秒减少一层"
	config.bfDir["<虚弱>"] = "减少20%防御，减少10%攻击，每两秒减少一层"
	config.bfDir["<冷却提升>"] = "提升3%冷却，无法叠加效果，每两秒减少一层"
	config.bfDir["<攻速提升>"] = "提升10%攻速，无法叠加效果，每两秒减少一层"
	config.bfDir["<闪避提升>"] = "提升5%闪避，无法叠加效果，每两秒减少一层"
	config.bfDir["<免伤提升>"] = "提升20%免伤，无法叠加效果，每两秒减少一层"
	config.bfDir["<增伤提升>"] = "提升10%增伤，无法叠加效果，每两秒减少一层"
	config.bfDir["<禁止复活>"] = "携带单位在Buff持续时间内死亡无法复活，每两秒减少一层"
	config.bfDir["<极寒气息>"] = "携带单位被治疗效果降低30%，无法叠加效果，每两秒减少一层"
	config.bfDir["<深海战意>"] = "增加5%增伤，可叠加效果，每两秒减少一层"
	config.bfDir["<血脉激发>"] = "增加20%增伤，20%吸血，持续4秒，4秒后承受+20%，持续2秒；无法叠加效果"
	config.bfDir["<神灵暴印>"] = "携带者受到暴击时触发，每层造成施法者生命上限4%伤害，最多叠加10层，无法驱散，引爆时消耗当前所有层数"
	config.bfDir["<烈焰灼烧>"] = "每秒造成<施法菲尼克斯生命上限 * 7%>的真实生命值伤害[上场菲尼克斯越多，系数越低，最低3%]，无法叠加效果，每秒减少一层"
	config.bfDir["<反弹护盾>"] = "受到攻击时，攻击者将受到本次攻击的20%伤害，无法叠加效果，无法驱散，每两秒减少一层"
	config.bfDir["<魔音散发>"] = "携带者使得其九宫格范围内友军每秒有33%概率附加1层<混乱>，附加混乱时，对其造成施法者33%魔法伤害，每两秒减少一层"
	call_deferred("anehekinit")
	print("塔防之光Mod加载就绪")
	pass
#初始化
func anehekinit():
	if globalData.infoDs.has("g_AneHekBase"):
		base = globalData.infoDs["g_AneHekBase"]
		path = chaData.infoDs["cTDW"].dir
	if base != null:
		base.connect("onLoadGame",self,"load")#继续游戏
		base.connect("onNewGame",self,"newGame")#开一局新游戏
		base.connect("onSaveGame",self,"backTitle")#返回标题（保存）
		utils = globalData.infoDs["g_AneHekUtils"]
		globalBonus = globalData.infoDs["g_AneHekGB"]
		ghandbook = globalData.infoDs["g_AneHekhandbook"]
		ghandbook2 = globalData.infoDs["g_AneHekhandbook1"]
		gDiff = globalData.infoDs["g_AneHekDiff"]
		gsell = globalData.infoDs["g_AneHekSell"]
	#	base.connect("onStartGame",self,"testss")
#func testss():
#	sys.main.player.connect("onDelCha",self,"123")
#重置初始化
func resetData():
	allflag = true
	uiflag =false
	layertxt = null
	settingpanel = null
	statiswindow = null
	statiscontainer = null
	summorsys = null
	shenqisys = null
	emit_signal("resetData")
#重置英雄数据集
func checkChaData():
	utils.x2.clear()
	utils.x3.clear()
	utils.x4.clear()
	utils.x5.clear()
	for i in chaData.rndPool.items:
		#print(i[0].id+"    ",i[1])
		if i[0].id.find("TD") == -1:
			allflag = false
		else:
			var tmp = i[0]
			match tmp.lv:
				1:
					utils.x2.append(tmp.id)
				2:
					utils.x3.append(tmp.id)
				3:
					utils.x4.append(tmp.id)
				4:
					utils.x5.append(tmp.id)
				#4:
	#print(utils.x2)
	#print(utils.x3)
	#print(utils.x4)
	#print(utils.x5)
#—————————————————————————————————加载类—————————————————————————————————#
func load():
	gameCtrl()
func newGame():
	gameCtrl()
	if base.getSetting("expertMode", false):
		for i in range(2):
			sys.main.player.addItem(sys.newItem(sys.rndListItem(itemData.rndPool.items)[0].id))
			yield(sys.get_tree().create_timer(0.01),"timeout")
	if base.getSetting("normalMode",false):
		var iid = sys.rndListItem(itemData.rndPool.items)[0].id
		while iid.find("bangle") != -1:
			iid = sys.rndListItem(itemData.rndPool.items)[0].id
		sys.main.player.addItem(sys.newItem(iid))
func backTitle():
	resetData()
#—————————————————————————————————加载类—————————————————————————————————#
#—————————————————————————————————控制类—————————————————————————————————#
func gameCtrl():
	resetData()
	checkChaData()
	sys.main.connect("onBattleReady", self, "onBattleReady")#敌方进场
	sys.main.connect("onBattleEnd", self, "onBattleEnd")#战斗结束
	sys.main.connect("onBattleStart", self, "onBattleStart")#战斗开始
	if allflag:
		if !base.getSetting("expertMode", false):
			if sys.main.player.maxHp != 400:
				sys.main.player.maxHp = 400
			sys.main.player.plusHp(400)
		#var bt=StyleBoxTexture.new()
		#var imt = utils.cIt("test/scbg.png")
		#imt.flags = 4
		#bt.set_texture(imt)
		#sys.main.get_node("ui/Panel").add_stylebox_override("panel",bt)	
		bgcnt = sys.rndRan(1,9)
		sys.main.get_node("scene/bg/bg").set_texture(utils.cIt("test/bg"+str(bgcnt)+".png"))	
		uiCtrl()
#敌方进场
func onBattleReady():#将召唤石位置进行改变&&显示名字
	if allflag:
		if base.getSetting("normalMode", false):
			sys.main.player.plusHp(20)
		if !base.getSetting("normalMode", false) && !base.getSetting("expertMode", false):
			sys.main.player.plusHp(400)
		layertxt.text="当前层数:%d" % int(sys.main.guankaMsg.lvStep - 2)
		gDiff.changediff()
		var chas = utils.getAllChas(1)
		for i in chas:
			if i.id == "cTDZ":
				var cells = i.cell
				if i.cell.x <5:
					var allcell = utils.getRndCell(2)
					while(sys.main.matCha(allcell)):
						allcell = utils.getRndCell(2)
					cells = allcell
				var chapool = ["cTDZ_2","cTDZ_1"]
				var cha = sys.main.newChara(sys.rndListItem(chapool),2)
				sys.main.map.add_child(cha)
				sys.main.setMatCha(cells, cha)
				i.delself()
#战斗结束
func onBattleEnd():
	if !allflag:return
	if sys.rndPer(10):
		utils.spoint += 1
		utils.refesh3()
		yield(sys.get_tree().create_timer(0.1),"timeout")
		sys.newBaseMsg("恭喜","获得1点技能点")
	var cl = sys.newItem(utils.getRndMaterial())
	var id = cl.id.replace("i_Hide_rw_","")
	utils[id] += 1
	print("获得材料："+cl.name)
	yield(sys.get_tree().create_timer(0.1),"timeout")
	if sys.rndPer(10):
		cl = sys.newItem(utils.getRndMaterial2())
		sys.main.player.addItem(cl)
	#cl.queue_free()
		print("获得材料：" + cl.name)
	pass
#战斗开始，清空统计版，替换召唤石
func onBattleStart():
	if !allflag:return
	statis1 = {}
	statis2 = {}
#确定是否改变ui
func uiCtrl():
	uiflag = true
	battleUI()
#战斗界面UI
func battleUI():
	var uiNode = sys.main.get_node("ui")#获得系统ui窗口node
	#加入层数显示
	layertxt = Label.new()
	layertxt.text="当前层数:{0}".format({"0":int(sys.main.guankaMsg.lvStep - 2)}) 
	layertxt.margin_left = 380
	layertxt.margin_right = 1180
	layertxt.align=0
	uiNode.add_child(layertxt)
	sys.main.get_node("ui/guanKa/Button/Sprite2").hide()
	layertxt.visible=true
	spoints = Label.new()
	spoints.text = "技能点：%d"%int(utils.spoint)
	spoints.set_position(Vector2(1370,212))
	uiNode.add_child(spoints)
	utils.cBtns(uiNode,self,"图鉴","handbook",[],Vector2(1550,202))
	buildBattleStatis()
	utils.cBtns(uiNode,self,"统计","battleStatis",[],Vector2(1550,152))
	utils.cBtns(uiNode,self,"背景","changebg",[],Vector2(1550,102))
	createshenqisys()
	utils.cBtns(uiNode,self,"商店","shop",[],Vector2(1550,52))
	utils.cBtns(uiNode,self,"装备","equipment",[],Vector2(1490,52))
"""	#控制面板
	createsettingpanel()
	var a1 = TextureButton.new()
	uiNode.add_child(a1)
	a1.texture_normal = utils.cIt("test/3.png")
	a1.set_size(Vector2(34,34))
	a1.set_position(Vector2(1370,510))
	a1.connect("pressed",self,"setting")
	#utils.cBtn("setting", uiNode, self)
	#战斗统计
	
	var a2 = TextureButton.new()
	uiNode.add_child(a2)
	a2.texture_normal = utils.cIt("test/2.png")
	a2.set_size(Vector2(34,34))
	a2.set_position(Vector2(1420,509))
	a2.connect("pressed",self,"battleStatis")
	#utils.cBtn("battleStatis", uiNode, self)
	#emit_signal("initMainUI")
	#先知系统
	createsummorsys()
	var a3 = TextureButton.new()
	uiNode.add_child(a3)
	a3.texture_normal = utils.cIt("test/4.png")
	a3.set_size(Vector2(34,34))
	a3.set_position(Vector2(1370,550))
	a3.connect("pressed",self,"summor")
	#utils.cBtn("summor", uiNode, self)
	#神器祈祷

	var a4 = TextureButton.new()
	uiNode.add_child(a4)
	a4.texture_normal = utils.cIt("test/5.png")
	a4.set_size(Vector2(34,34))
	a4.set_position(Vector2(1420,550))
	a4.connect("pressed",self,"shenqi")
	#utils.cBtn("shenqi", uiNode, self)
	#图鉴
	var a5 = TextureButton.new()
	uiNode.add_child(a5)
	a5.texture_normal = utils.cIt("test/6.png")
	a5.set_size(Vector2(34,34))
	a5.set_position(Vector2(1470,510))
	a5.connect("pressed",self,"handbook")
	#图鉴2
	var a6 = TextureButton.new()
	uiNode.add_child(a6)
	a6.texture_normal = utils.cIt("test/7.png")
	a6.set_size(Vector2(34,34))
	a6.set_position(Vector2(1520,510))
	a6.connect("pressed",self,"handbook2")
	#utils.cBtn("handbook", uiNode,self)
"""
#切换背景
func changebg():
	bgcnt += 1
	if bgcnt > 9:
		bgcnt = 1
	sys.main.get_node("scene/bg/bg").set_texture(utils.cIt("test/bg"+str(bgcnt)+".png"))	
#创建控制面板
func createsettingpanel():
	settingpanel = WindowDialog.new()
	settingpanel.set_size(Vector2(500,400))
	settingpanel.window_title = "控制面板"
	sys.main.get_node("ui").add_child(settingpanel)
	var gridList = GridContainer.new()
	gridList.columns = 3
	gridList.rect_position = Vector2(80,60)
	settingpanel.add_child(gridList)
	utils.cBtn("guide", gridList, self)
	utils.cBtn("Log", gridList, self)
	utils.cBtn("globalBonus", gridList, self)	
#创建战斗统计面板
func buildBattleStatis():
	statiswindow = WindowDialog.new()
	statiswindow.set_size(Vector2(700, 600))
	statiswindow.window_title = "战斗统计"
	sys.main.get_node("ui").add_child(statiswindow)
	utils.cBtn("selfStatis", statiswindow, self)
	utils.cBtn("enemyStatis", statiswindow, self)
	var statisScroll = ScrollContainer.new()
	statisScroll.name = "ScrollContainer"
	statisScroll.set_custom_minimum_size(Vector2(650, 400))
	statisScroll.rect_position = Vector2(30, 100)
	statisScroll.set_margin(0, 50)
	statiswindow.add_child(statisScroll)
	statiscontainer = VBoxContainer.new()
	statisScroll.add_child(statiscontainer)	
#创建先知系统面板
func createsummorsys():
	summorsys = WindowDialog.new()
	summorsys.set_size(Vector2(500,320))
	summorsys.window_title = "先知系统"
	sys.main.get_node("ui").add_child(summorsys)
	var gridList = GridContainer.new()
	gridList.columns = 4
	gridList.rect_position = Vector2(40,60)
	summorsys.add_child(gridList)
	for i in range(4):
		utils.cBtn("dc"+str(i), gridList, self)
	var gridList1 = GridContainer.new()
	gridList1.columns = 4
	gridList1.rect_position = Vector2(90,110)
	summorsys.add_child(gridList1)
	for i in range(3):
		utils.cBtn("dc"+str(i+4), gridList1, self)
	var gridList2 = GridContainer.new()
	gridList2.columns = 4
	gridList2.rect_position = Vector2(40,160)
	summorsys.add_child(gridList2)
	for i in range(4):
		utils.cBtn("sl"+str(i), gridList2, self)
	var gridList3 = GridContainer.new()
	gridList3.columns = 4
	gridList3.rect_position = Vector2(90,210)
	summorsys.add_child(gridList3)
	for i in range(3):
		utils.cBtn("sl"+str(i+4), gridList3, self)	
	var lb = utils.cRLb("[color=green]注：十连九折优惠[/color]", summorsys, Vector2(250,110))
	lb.rect_position = Vector2(155,260)
#创建商店界面
func createshenqisys():
	shenqisys = WindowDialog.new()
	shenqisys.set_size(Vector2(500,400))
	shenqisys.window_title = "塔防商店"
	sys.main.get_node("ui").add_child(shenqisys)
	var gridList = GridContainer.new()
	gridList.columns = 2
	gridList.rect_position = Vector2(250,30)
	shenqisys.add_child(gridList)
	for i in range(6):
		utils.cBtn("sqqd"+str(i), gridList, self)
	utils.cBtns(shenqisys,self,"材料出售","sellshop",[],Vector2(308,200))
	utils.cBtns(shenqisys,gsell,"购买装备","sellnow",[],Vector2(70,90))
	utils.cBtns(shenqisys,gsell,"购买材料","sellnow",[],Vector2(70,200))
	
	var lb = utils.cRLb("[color=green]注1:材料一次100,角色一次200,装备一次300\n注2:出售的装备和材料每10场战斗刷新一次\n注3:材料价格：50 或 67,装备价格：250", shenqisys, Vector2(450,110))
	lb.rect_position = Vector2(30,260)
#材料出售
func sellshop():
	gsell.showit()
#唤出神器祈祷
func shop():
	gsell.freshsellshow(shenqisys)
	shenqisys.popup_centered()
#唤出先知系统
func summor():
	summorsys.popup_centered()
#唤出控制面板
func setting():
	settingpanel.popup_centered()
#唤出图鉴
func handbook():
	ghandbook.openit()
#唤出神器图鉴
func equipment():
	#sys.newBaseMsg("提示","神器图鉴暂时删除，神器兑换功能暂时无法使用")
	ghandbook2.createIllstrate()
	ghandbook2.openit()
#唤出全局buff统计面板（待完成）
func gB():
	#globalBonus.showRecord()
	pass
#更新日志
func log():
	var helpPop = sys.newMsg("jiangLiMsg")
	helpPop.get_node("Panel/Label").text = "更新日志"
	var panel = helpPop.get_node("Panel")
	var textBox = utils.cRLb(utils.readChangeLog(), panel, Vector2(1000,400))
	textBox.margin_top = 80
	textBox.margin_left = 50
	helpPop.popup()
#mod指引
func guide():
	var guidePop = sys.newMsg("jiangLiMsg")
	guidePop.get_node("Panel/Label").text = "Mod指引"
	var panel = guidePop.get_node("Panel")
	var textBox = utils.cRLb(utils.readGuideLog(), panel, Vector2(1000,400))
	textBox.margin_top = 80
	textBox.margin_left = 50
	guidePop.popup()
#当前加成
func globalBonus():
	var uinode = sys.main.get_node("ui")
	var win = utils.cWin(uinode,"当前加成",Vector2(700,500))
	win.popup_exclusive = true
	var sc = utils.cSc(win,Vector2(600,375),Vector2(50,25))
	var vb = utils.cVb(sc)
	var gevent = globalData.infoDs["g_AneHekEvent"]
	if gevent.gbuffs.size() || gevent.bbuffs.size():
		for i in gevent.gbuffs:
			if i == null:break
			utils.cRLb("[color=#00FF00]" + i["txt"] + str(int(i.cnt)) + " 场战斗[/color]",vb,Vector2(600,35))
		for i in gevent.bbuffs:
			if i == null:break
			utils.cRLb("[color=red]" + i["txt"] + str(int(i.cnt)) + " 场战斗[/color]",vb,Vector2(600,35))
	else:
		utils.cRLb("[color=yellow]无[/color]",vb,Vector2(600,35))
	win.popup_centered()
#—————————————————————————————————控制类—————————————————————————————————#
#—————————————————————————————————抽奖类—————————————————————————————————#
func sqqd0():
	sum(0,5,0)
func sqqd1():
	sum(0,10,0)
func sqqd2():
	sum(5,0,0)
func sqqd3():
	sum(10,0,0)
func sqqd4():
	sum(5,0,1)
func sqqd5():
	sum(10,0,1)
func sum(cnt1 = 1,cnt2 = 1,flag = 1):#物品数量，角色数量，材料还是装备
	if !cnt1:
		if !checkgold(cnt2 * 200):return
	else:
		if !flag:
			if !checkgold(cnt1 * 100):return
		else:
			if !checkgold(cnt1 * 300):return
	utils.rollItem(cnt1,cnt2,"抽奖结果",flag)
	pass
#判断金币数是否足够
func checkgold(goldneed):
	if goldneed  <= sys.main.player.gold:
		sys.main.player.plusGold(-goldneed)
		return true
	else:
		sys.newBaseMsg("提示","金币不足{0}/{1}".format({"0":int(sys.main.player.gold),"1":int(goldneed)}))
		return false
#—————————————————————————————————统计类—————————————————————————————————#
#载入并唤出统计界面
func battleStatis():
	loadStatis(1)
	statiswindow.popup_centered()
#载入统计数据(替换名字前缀待完成)
func loadStatis(team = 1):
	for i in statiscontainer.get_children():
		i.queue_free()
	var statis
	if team == 1:
		statis = statis1
		utils.cRLb("[color=green]我方数据统计：[/color]", statiscontainer)
	else:
		statis = statis2
		utils.cRLb("[color=red]敌方数据统计：[/color]", statiscontainer)
	var vals = statis.values()
	vals.sort_custom(self, "sortStatis")
	var hb = utils.cHb(statiscontainer)
	var v1 = utils.cVb(hb)
	var v2 = utils.cVb(hb)
	var v3 = utils.cVb(hb)
	var v4 = utils.cVb(hb)
	var v5 = utils.cVb(hb)
	utils.cRLb("角色名", v1,Vector2(140,50))
	utils.cRLb("[color=red]伤害量", v2,Vector2(130,50))
	utils.cRLb("[color=yellow]承伤量", v3,Vector2(130,50))
	utils.cRLb("[color=green]治疗量", v4,Vector2(130,50))
	utils.cRLb("      ", v5,Vector2(80,50))
	for i in vals:
		#var names = i.name.replace("[Ⅲ]","[3]").replace("[Ⅳ]","[4]").replace("[Ⅴ]","[5]")
		utils.cRLb("{0}".format({"0":i.name}), v1,Vector2(140,60))
		var a = utils.cRLb("[color=red]{1}".format({"1":int(i.damage)}), v2,Vector2(130,60))
		a.push_align(1)
		a.scroll_active = false
		a = utils.cRLb("[color=yellow]{2}".format({"2":int(i.hurt)}), v3,Vector2(130,60))
		a.push_align(1)
		a.scroll_active = false
		a = utils.cRLb("[color=green]{3}".format({"3":int(i.deal)}), v4,Vector2(130,60))
		a.push_align(1)
		a.scroll_active = false
		utils.cBtns(v5,self,"详情","showdetail",[i])
func showdetail(i):
	var win = utils.cWin(statiswindow,"统计详情",Vector2(500,300))
	var gridList = GridContainer.new()
	gridList.columns = 3
	gridList.rect_position = Vector2(50,30)
	win.add_child(gridList)
	var sc = ScrollContainer.new()
	var v = utils.cVb(sc)
	utils.cBtns(gridList,self,"伤害","changedetail",[0,i,v])
	utils.cBtns(gridList,self,"承伤","changedetail",[1,i,v])
	utils.cBtns(gridList,self,"治疗","changedetail",[2,i,v])
	sc.set_custom_minimum_size(Vector2(400,180))
	sc.rect_position = Vector2(50,100)
	win.add_child(sc)
	win.popup_centered()
	v = changedetail(0,i,v)
	
func changedetail(pos,i,v):
	for j in v.get_children():
		j.queue_free()
	var h = utils.cHb(v)
	var a = utils.cVb(h)
	var b = utils.cVb(h)
	utils.cRLb("角色名", a,Vector2(160,50))
	if !pos: 
		utils.cRLb("[color=yellow]承伤量", b,Vector2(130,50))
	elif pos == 1:
		utils.cRLb("[color=red]伤害量", b,Vector2(130,50))
	else:
		utils.cRLb("[color=green]承疗量", b,Vector2(130,50))
	var vals = i.values()
	var txt = []
	for j in vals:
		if j is Dictionary:
			txt.append(j)
	txt.sort_custom(self,"sortd"+str(pos))
	for j in txt:
		var c 
		if !pos: 
			if j.dmg == 0:continue
			c = utils.cRLb("[color=yellow]{0}".format({"0":int(j.dmg)}), b,Vector2(130,50))
		elif pos == 1:
			if j.hurt == 0:continue
			c = utils.cRLb("[color=red]{1}".format({"1":int(j.hurt)}), b,Vector2(130,50))
		else:
			if j.heal == 0:continue
			c = utils.cRLb("[color=green]{2}".format({"2":int(j.heal)}), b,Vector2(130,50))
		c.scroll_active = false
		utils.cRLb("{0}".format({"0":j.name}), a,Vector2(160,50))
	if b.get_child_count() == 1:
		utils.cRLb("无", a,Vector2(160,50))
	return v
	
func sortd0(a,b):
	return a.dmg > b.dmg
func sortd1(a,b):
	return a.hurt > b.hurt
func sortd2(a,b):
	return a.heal > b.heal
#排序
func sortStatis(a, b):
	return a.damage > b.damage
#获取英雄队伍和名字
func getDefaultStatis(cha):
	return {"damage":0, "hurt":0, "deal":0, "team":cha.team, "name":cha.chaName}
#获取单个英雄战斗统计
func getStatisByCha(cha):
	var statis
	if cha.team == 1:
		statis = statis1.get(cha, getDefaultStatis(cha))
	else:
		statis = statis2.get(cha, getDefaultStatis(cha))
	return statis
#设置显示数据
func setStatisByCha(cha, statis):
	if cha.team == 1:
		statis1[cha] = statis
	else:
		statis2[cha] = statis
	#if sys.test:
	#	print(statis)
#————————————————————————————————————————————Buff————————————————————————————————————————————#
class b_weisuo:#畏缩
	extends Buff
	func _init(lv = 1):
		attInit()
		id = "b_weisuo"
		life = lv
		isNegetive = true
	func init():
		
		pass
	func _connect():
		pass
	func _upS():
		att.atkL = - ( 0.20 + life * 0.02 ) * pw
		#eff.amount = clamp(life,1,25)
class b_duwu:#毒雾
	extends Buff
	func _init(lv = 1):
		attInit()
		id = "b_duwu"
		life = lv 
		isNegetive = true
	func init():
		pass
	func _connect():
		pass
	func _upS():
		att.reHp = - 0.50 * pw
		att.spd = - 0.15 * pw
		#eff.amount = clamp(life,1,25)
class b_bingdong:#冰冻
	extends Buff
	var iscontrol:bool
	func _init(lv = 1):
		attInit()
		id = "b_bingdong"
		life = lv 
		isNegetive =true
		self.iscontrol = true
	func init():
		pass
	var eff2
	var tmp
	var utils = globalData.infoDs["g_AneHekUtils"]
	func _connect():
		._connect()
		tmp = masCha.aiOn
		masCha.aiOn = false
		if masCha.get("type") == "BOSS":
			life /= 2
		if !masCha.isDeath:
			eff2 = sys.newEff("animEff", masCha.position)
			eff2.setImgs(utils.path + "/eff/bingdong", 1, true)
			#eff2.setText("冰冻","99FFFF")
			eff2.scale *= 1
			eff2.normalSpr.position = Vector2(10,-10)

	func _del():
		._del()
		masCha.aiOn = tmp
		if is_instance_valid(eff2):
			eff2.queue_free()
	func _process(delta):
		if masCha != null && is_instance_valid(eff2):
			eff2.position = masCha.position
		else:
			eff2.queue_free()
class b_shenzhan:#神战
	extends Buff
	var canremove:bool
	func _init(lv = 1):
		attInit()
		id = "b_shenzhan"
		life = 100000
		isNegetive = false
		canremove = false
	func init():
		pass
	var cnt = 0
	func _upS():
		cnt += 1
		if cnt % 5 == 0:
			lv = lv + 1
		#print(lv)
		att.atkR = 0.034 * min(lv + 1,5) * pw
class b_zhiliao:#治疗加成
	extends Buff
	func _init(lv = 1):
		attInit()
		id = "b_zhiliao"
		isNegetive = false
		life = lv * 100000
	func init():
		pass
	var lvs:int
	func addlvs(a:int):
		lvs = a
class b_xuanyun:#眩晕
	extends Buff
	var iscontrol:bool
	func _init(lv = 1):
		attInit()
		id = "b_xuanyun"
		life = lv * 2
		isNegetive =true
		self.iscontrol = true
	func init():
		pass
	var eff2
	var tmp
	var utils = globalData.infoDs["g_AneHekUtils"]
	func _connect():
		._connect()
		tmp = masCha.aiOn
		masCha.aiOn = false
		if masCha.get("type") == "BOSS":
			life /= 2
		if !masCha.isDeath:
			eff2 = sys.newEff("animEff", masCha.position)
			eff2.setImgs(utils.path + "/eff/xuanyun", 8, true)
			#eff2.setText("冰冻","99FFFF")
			eff2.scale *= 1
			eff2.normalSpr.position = Vector2(10,-135)

	func _del():
		._del()
		masCha.aiOn = tmp
		if is_instance_valid(eff2):
			eff2.queue_free()
	func _process(delta):
		if masCha != null && is_instance_valid(eff2):
			eff2.position = masCha.position
		else:
			eff2.queue_free()
class b_jinliao:#禁疗
	extends Buff
	func _init(lv = 1):
		attInit()
		life = lv * 2
		isNegetive = true
	func init():
		pass
	var tmp
	func _connect():
		._connect()
		if masCha.att.reHp != -1:
			tmp = masCha.att.reHp
			masCha.att.reHp = -1
	func _del():
		._del()
		masCha.att.reHp = tmp
	func _upS():
		if masCha.att.reHp != -1:
			masCha.att.reHp = -1
class b_zs:#灼烧
	extends Buff
	var cha = null
	var exdmg = 0
	func _init(lv = 1,cha = null,exdmg = 0):
		attInit()
		id = "b_zs"
		life = lv 
		isNegetive = true
		self.cha = cha
		self.exdmg = exdmg
	func init():
		pass
	var dmg = max(cha.att.atk,cha.att.mgiAtk) * 0.14
	func _upS():
		var eff = sys.newEff("numHit",masCha.position,false,1)
		eff.setText("灼烧!","FF0000")
		eff.anim.set_speed_scale(0.7)
		if cha != null:
			cha.hurtChara(masCha,dmg * life + exdmg,Chara.HurtType.REAL,Chara.AtkType.EFF)
		else:
			masCha.hurtChara(masCha,dmg * life + exdmg,Chara.HurtType.REAL,Chara.AtkType.EFF)
class b_zd:#中毒
	extends Buff
	var cha = null
	func _init(lv = 1,cha = null):
		attInit()
		id = "b_zd"
		life = lv 
		isNegetive = true
		self.cha = cha
	func init():
		pass
	var dmglimit = max(cha.att.atk,cha.att.mgiAtk) * 10
	func _upS():
		var eff = sys.newEff("numHit",masCha.position,false,1)
		var dmg:int = masCha.att.maxHp * 0.05
		if dmg > dmglimit:dmg = dmglimit
		eff.setText("中毒!-" + str(dmg),"FF0000")
		eff.anim.set_speed_scale(0.5)
		if cha!= null:
			cha.hurtChara(masCha,dmg,Chara.HurtType.REAL,Chara.AtkType.EFF)
		else:
			masCha.hurtChara(masCha,dmg,Chara.HurtType.REAL,Chara.AtkType.EFF)
class b_mp:#魔法破甲
	extends Buff
	func _init(lv = 1):
		attInit()
		id = "b_mp"
		life = lv
		isNegetive=true
	func init():
		pass
	func _connect():
		pass
	func _upS():
		att.mgiDefL = - 0.20 * pw
class b_pj:#破甲
	extends Buff
	func _init(lv = 1):
		attInit()
		id = "b_pj"
		life = lv
		isNegetive=true
	func init():
		pass
	func _connect():
		pass
	func _upS():
		att.defL = - 0.20 * pw
class b_hl:#混乱
	extends Buff
	var iscontrol:bool
	func _init(lv = 1):
		attInit()
		id = "b_hl"
		life = lv * 2
		isNegetive = true
		self.iscontrol = true
	func init():
		pass
	func _connect():
		._connect()
		att.cd = -(att.cd + 1)
	func _del():
		._del()
		masCha.aiCha = null
	func _upS():
		var chas = masCha.getAllChas(0)
		masCha.aiCha = sys.rndListItem(chas)
class b_shengdun:#圣盾
	extends Buff
	var num = 0
	func _init(num = 1):
		attInit()
		id = "b_shengdun"
		self.num += num
	func _connect():
		masCha.connect("onHurt", self, "onHurt")
	func onHurt(atkInfo:AtkInfo):
		if atkInfo.hurtVal > 0 && not atkInfo.isMiss and num > 0 and atkInfo.atkType == Chara.AtkType.NORMAL:
			atkInfo.hurtVal = 0
			num -= 1
		if num <= 0:
			isDel = true
class b_cxzl:#持续治疗
	extends Buff
	var cha
	var num = 0
	var canremove:bool
	func _init(lv = 1,num = 1,cha = null):
		attInit()
		id ="b_cxzl"
		life = 100000
		self.num = num
		self.cha = cha
		self.canremove = false
	func _connect():
		pass
	var cnt = 0
	func _upS():
		cnt += 1
		if cnt % 2 == 0:
			cha.healCha(masCha,num)
		if cnt / 2.0 > 2:isDel = true
class b_zhenfen:#振奋
	extends Buff
	func _init(lv = 1):
		attInit()
		id = "b_zhenfen"
		life = lv * 2
	func _connect():
		pass
	func _upS():
		att.atkL = 0.30 * pw
class b_fs:#法术反噬
	extends Buff
	var cha 
	var num
	var cnt = 0
	func _init(lv = 1,cha = null,num = 1):
		attInit()
		id = "b_fs"
		self.cha = cha
		self.num = num
		life = lv * 2
		isNegetive = true
	func _connect():
		masCha.connect("onAtkChara",self,"run")
	func run(atkinfo:AtkInfo):
		if cha != null:
			cha.hurtChara(masCha,num,Chara.HurtType.REAL,Chara.AtkType.EFF)
		else:
			masCha.hurtChara(masCha,num,Chara.HurtType.REAL,Chara.AtkType.EFF)
class b_shihua:#石化
	extends Buff
	func _init(lv = 1):
		attInit()
		id = "b_shihua"
		life = lv * 2
		isNegetive =true
	func init():
		pass
	var tmp
	#var eff2
	#var utils = globalData.infoDs["g_AneHekUtils"]
	func _connect():
		._connect()
		tmp = masCha.aiOn
		masCha.aiOn = false
		if masCha.get("type") == "BOSS":
			life /= 2
		#eff2 = sys.newEff("animEff", masCha.position)
		#eff2.setImgs(utils.path + "/eff/xuanyun", 8, true)
		#eff2.setText("冰冻","99FFFF")
		#eff2.scale *= 1
		#eff2.normalSpr.position = Vector2(10,-135)
	func _del():
		._del()
		masCha.aiOn = tmp
		#if is_instance_valid(eff2):
		#	eff2.queue_free()
	#func _process(delta):
		#if masCha != null && is_instance_valid(eff2):
		#	eff2.position = masCha.position
	func _upS():
		#if masCha == null || masCha.att.hp <= 0:
		#	eff2.queue_free()	
		att.defL = - 0.1 * pw
		att.mgiDefL = - 0.1 * pw
class b_chaofeng:#嘲讽
	extends Buff
	var cha = null
	var iscontrol:bool 
	func _init(lv = 1,cha = null):
		attInit()
		id = "b_chaofeng"
		life = lv * 2
		isNegetive = true
		self.iscontrol = true
	func init():
		pass
	func _connect():
		._connect()
		att.cd = -(att.cd + 1)
		masCha.aiCha = cha
	func _del():
		masCha.aiCha = null
		._del()
class b_chenmo:#沉默
	extends Buff
	var cha = null
	func _init(lv = 1,cha = null):
		attInit()
		id = "b_chenmo"
		life = lv
		isNegetive = true
	func init():
		pass
	func _connect():
		._connect()
		att.cd = -(att.cd + 1)
class b_lijian:#离间
	extends Buff
	var iscontrol:bool 
	func _init(lv = 1):
		attInit()
		id = "b_lijian"
		life = lv * 2
		isNegetive = true
		self.iscontrol = true
	func init():
		pass

	func _connect():
		._connect()
		att.cd = -(att.cd + 1)
		var chas = masCha.getAllChas(2)
		masCha.aiCha = sys.rndListItem(chas)

	func _del():
		masCha.aiCha = null
		._del()
class b_lqts:#冷却提升
	extends Buff
	func _init(lv = 1):
		attInit()
		life = lv * 2
		id = "b_lqts"
	func init():
		pass
	func _upS():
		att.cd = 0.03 * pw
class b_sbts:#闪避提升
	extends Buff
	func _init(lv = 1):
		attInit()
		life = lv * 2
		id = "b_sbts"
	func init():
		pass
	func _upS():
		att.dod = 0.05 * pw
class b_baonu:#暴怒
	extends Buff
	func _init(lv = 1):
		attInit()
		id = "b_baonu"
		life = lv * 2
	func _connect():
		pass
	func _upS():
		att.cri = 0.10 * pw
class b_chenshui:#沉睡
	extends Buff
	var iscontrol:bool
	func _init(lv = 1):
		attInit()
		id = "b_chenshui"
		life = lv * 2
		isNegetive =true
		self.iscontrol = true
	func init():
		pass
	var tmp
	#var eff2
	#var utils = globalData.infoDs["g_AneHekUtils"]
	func _connect():
		._connect()
		tmp = masCha.aiOn
		masCha.aiOn = false
		if masCha.get("type") == "BOSS":
			life /= 2
		masCha.connect("onHurt",self,"run")
		#eff2 = sys.newEff("animEff", masCha.position)
		#eff2.setImgs(utils.path + "/eff/xuanyun", 8, true)
		#eff2.setText("冰冻","99FFFF")
		#eff2.scale *= 1
		#eff2.normalSpr.position = Vector2(10,-135)
	func _del():
		._del()
		masCha.aiOn = tmp
		#if is_instance_valid(eff2):
		#	eff2.queue_free()
	#func _process(delta):
		#if masCha != null && is_instance_valid(eff2):
		#	eff2.position = masCha.position
	#func _upS():
		#if masCha == null || masCha.att.hp <= 0:
		#	eff2.queue_free()	
	var cnt = 0
	func run(atkinfo:AtkInfo):
		if atkinfo.atkType != Chara.AtkType.EFF:
			cnt += 1
			if cnt  == 1:
				if sys.rndPer(50):
					isDel = true
			if cnt == 2:
				isDel = true 
class b_sssh:#免伤提升
	extends Buff
	func _init(lv = 1):
		attInit()
		life = lv * 2
		id = "b_sssh"
	func init():
		pass
	func _upS():
		att.defR = 0.2 * pw
class b_jzfh:#禁止复活
	extends Buff
	func _init(lv = 1):
		attInit()
		life = lv * 2
		id ="b_jzfh"
	func init():
		pass
	var tmp
	func _connect():
		._connect()
		if masCha.get("canre") != null:
			tmp = masCha.canre
			masCha.canre = false

	func _del():
		._del()
		if masCha.get("canre") != null && masCha.isDeath == false && masCha != null:
			masCha.canre = tmp
class b_jhqx:#极寒气息
	extends Buff
	func _init(lv = 1):
		attInit()
		life = lv * 2
		id = "b_jhqx"
	func init():
		pass
	func _upS():
		att.reHp = - 0.3 * pw
class b_pingnu:#平怒
	extends Buff
	func _init(lv = 1):
		attInit()
		id = "b_pingnu"
		life = lv * 2
	func _connect():
		pass
	func _upS():
		att.cri = -0.15 * pw
class b_shzy:#深海战意
	extends Buff
	var canremove:bool = false
	func _init(lv = 1):
		attInit()
		id = "b_shzy"
		life = lv * 2
	func _connect():
		pass
	func _upS():
		var cnt = int(life / 4) + 1
		#print(life)
		if int(life) % 4 == 0:cnt -=1
		att.atkR = 0.05 * cnt * pw
class b_fthd:#反弹护盾
	extends Buff
	var canremove:bool = false
	func _init(lv = 1):
		attInit()
		life = lv * 2
	func _connect():
		._connect()
		masCha.connect("onHurt",self,"run")
	func run(atkinfo):
		if atkinfo.hitCha != null && atkinfo.atkType != Chara.AtkType.EFF:
			masCha.hurtChara(atkinfo.hitCha,atkinfo.hurtVal,atkinfo.hurtType,Chara.AtkType.EFF)
class b_lyzs:#烈焰灼烧
	extends Buff
	var cha = null
	var exdmg = 0
	var dmg = 0
	func _init(lv = 1,cha = null,exdmg = 0):
		attInit()
		id = "b_lyzs"
		life = lv 
		isNegetive = true
		self.cha = cha
		self.exdmg = exdmg
		self.dmg = cha.att.maxHp * 0.07
	func init():
		pass
	var utils = globalData.infoDs["g_AneHekUtils"]
	func _upS():
		var eff = sys.newEff("numHit",masCha.position,false,1)
		eff.setText("烈焰灼烧!","FF0000")
		eff.anim.set_speed_scale(0.7)
		var chas = masCha.getAllChas(1)
		var cnt = 0
		for i in chas:
			if i.id.find("Hfnks") != -1:
				cnt += 1
		if cha != null:dmg = cha.att.maxHp * (max(0.03,0.07 - (cnt-1) * 0.01))
		if cha != null:
			cha.hurtChara(masCha,dmg + exdmg,Chara.HurtType.REAL,Chara.AtkType.EFF)
		else:
			masCha.hurtChara(masCha,dmg + exdmg,Chara.HurtType.REAL,Chara.AtkType.EFF)
class b_zsts:#增伤提升
	extends Buff
	func _init(lv = 1):
		attInit()
		life = lv * 2
		id = "b_zsts"
	func init():
		pass
	func _upS():
		att.atkR = 0.1 * pw
class b_gsts:#攻速提升
	extends Buff
	func _init(lv = 1):
		attInit()
		life = lv * 2
		id = "b_gsts"
	func init():
		pass
	func _upS():
		att.spd = 0.1 * pw
class b_zuzhou:#诅咒
	extends Buff
	var cnt:int = 0
	var times
	var cha
	var dmg
	func _init(cnt = 1,cha = null):
		attInit()
		id = "b_zuzhou"
		self.cnt += cnt
		self.cha = cha
		isNegetive = true

	func _connect():
		._connect()
		times = 0
		dmg = max(cha.att.atk,cha.att.mgiAtk) * 0.3

	func init():
		pass

	func _upS():
		if times % 2 == 0 && time != 0 && cnt:
			var eff = sys.newEff("numHit",masCha.position,false,1)
			eff.setText("诅咒爆发!","CC00FF")
			eff.anim.set_speed_scale(0.7)
			if cha != null:
				cha.hurtChara(masCha,dmg,Chara.HurtType.REAL,Chara.AtkType.EFF)
			else:
				masCha.hurtChara(masCha,dmg,Chara.HurtType.REAL,Chara.AtkType.EFF)
			cnt -= 1
			if !cnt:
				self.isDel = true
		times += 1
		._upS()
class b_slby:#神灵暴印
	extends Buff
	var canremove:bool = false
	var cnt:int = 0
	var cha
	func _init(cnt = 1,cha = null):
		attInit()
		self.cnt += cnt
		self.cnt = min(10,cnt)
		self.cha = cha 

	func _connect():
		._connect()
		masCha.connect("onHurtEnd",self,"run")
		
	func run(atkinfo):
		if atkinfo.isCri && atkinfo.atkType != Chara.AtkType.EFF:
			if cha!=null:
				cha.hurtChara(masCha,cnt * cha.att.maxHp * 0.04,Chara.HurtType.REAL,Chara.AtkType.EFF)
			else:
				masCha.hurtChara(masCha,cnt * cha.att.maxHp * 0.04,Chara.HurtType.REAL,Chara.AtkType.EFF)
			cnt = 0
			self.isDel = true
class b_d:#毒
	extends Buff
	var exdmg = 0
	func _init(lv,exdmg):
		attInit()
		life = lv * 3
		self.exdmg = exdmg
		id = "b_d"
	func _upS():
		masCha.hurtChara(masCha,exdmg,Chara.HurtType.PHY,Chara.AtkType.EFF)
class b_xmjf:#血脉激发
	extends Buff
	func _init(lv):
		attInit()
		id = "b_xmjf"
		life = lv * 6
	func _upS():
		if life > 2:
			att.atkR = 0.2 * pw
			att.suck = 0.2 * pw
		else:
			att.defR = -0.2
class b_xr:#虚弱
	extends Buff
	func _init(lv):
		attInit()
		life = lv * 2
		id = "b_xr"
		isNegetive = true
		att.defL = -0.2
		att.mgiDefL = -0.2
		att.atkL = -0.1

class b_duzhong:#毒种
	extends Buff
	var canremove:bool = false
	var cnt = 0
	var item 
	func _init(lv = 1,cnt = 1,item = null):
		attInit()
		id = "b_duzhong"
		life = lv
		self.cnt = cnt
		self.item = item
	func _del():
		._del()
		if item:
			item.target = null
	func _connect():
		masCha.connect("onHurt",self,"run")

	func run(atkinfo):
		atkinfo.hurtVal *= 1.05
class b_bingzhong:#冰种
	extends Buff
	var canremove:bool = false
	var cnt = 0
	var item
	func _init(lv = 1,cnt = 1,item = null):
		attInit()
		id = "b_bingzhong"
		life = lv
		self.cnt = cnt
		self.item = item
	func _del():
		._del()
		if item:
			item.target = null

	func _connect():
		masCha.connect("onHurt",self,"run")

	func run(atkinfo):
		atkinfo.hurtVal *= 1.05

class b_huozhong:#火种
	extends Buff
	var canremove:bool = false
	var cnt = 0
	var huolist = ["b_shaoZhuo","b_zs","b_hq","hzrs"]
	var exdmg
	var item
	func _init(lv = 1,cnt = 1,exdmg = 0,item = null):
		attInit()
		id = "b_huozhong"
		life = lv
		self.cnt = cnt
		self.exdmg = exdmg
		self.item = item

	func _del():
		._del()
		if item:
			item.target = null

	func _connect():
		masCha.connect("onHurt",self,"run")
		masCha.connect("onAddBuff",self,"run2")

	func run(atkinfo):
		atkinfo.hurtVal *= 1.05

	func run2(buff):
		yield(sys.get_tree().create_timer(0.05),"timeout")
		if buff.isDel:return
		if huolist.find(buff.id) != -1:
			buff.isDel = true
			masCha.hurtChara(masCha,masCha.att.maxHp * 0.05 + exdmg,Chara.HurtType.REAL,Chara.AtkType.EFF)
			self.isDel = true
class b_vague:
	extends Buff
	func _init(lv):
		attInit()
		life = lv
		id = "b_vague"
#————————————————————————————————————————————Buff————————————————————————————————————————————#